package com.xuelang.pipeline.artifact.entry.resource;

import com.xuelang.pipeline.artifact.app.resource.RepositoryPackageService;
import com.xuelang.pipeline.artifact.client.common.request.PageParam;
import com.xuelang.pipeline.artifact.client.common.result.ApiResult;
import com.xuelang.pipeline.artifact.client.common.result.PageRecord;
import com.xuelang.pipeline.artifact.client.resource.IRepositoryPackageService;
import com.xuelang.pipeline.artifact.client.resource.dto.RepositoryPackageDTO;
import com.xuelang.pipeline.artifact.client.resource.dto.RepositoryPackageQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 制品包 web控制类
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
@Slf4j
@RestController
@RequestMapping("/repository-package")
public class RepositoryPackageController implements IRepositoryPackageService {

    @Autowired
    private RepositoryPackageService repositoryPackageService;

    @Override
    public ApiResult<PageRecord<RepositoryPackageDTO>> pageRepositoryPackageList(PageParam<RepositoryPackageQuery> dtoPageParam) {
        return ApiResult.success(repositoryPackageService.pageList(dtoPageParam));
    }

    @Override
    public ApiResult<List<RepositoryPackageDTO>> conditionalRepositoryPackageList(RepositoryPackageQuery repositoryPackageQuery) {
        return ApiResult.success(repositoryPackageService.list(repositoryPackageQuery));
    }

    @Override
    public ApiResult<Boolean> deleteRepositoryPackage(String packageUuid) {
        return ApiResult.success(repositoryPackageService.delete(packageUuid));
    }

    @Override
    public ApiResult<RepositoryPackageDTO> queryRepositoryPackage(String packageUuid) {
        return ApiResult.success(repositoryPackageService.query(packageUuid));
    }

}